from fastapi import FastAPI

from .config import appSettings
from .dependencies import request_id
from .exception.base import golbal_exception_handlers
from .middlewares.error import ErrorHandingMiddleware
from .middlewares.log import LoggingMiddleware
from .middlewares.request_id import RequestIDMiddleware
from .routers import photo

docs_url_value = "/docs" if appSettings.environment == "development" else None
app = FastAPI(docs_url=docs_url_value, redoc_url=None, exception_handlers=golbal_exception_handlers)

app.add_middleware(ErrorHandingMiddleware)
app.add_middleware(LoggingMiddleware)
app.add_middleware(RequestIDMiddleware)


app.include_router(photo.router)


@app.get("/")
async def read_system():
  return {
    "app_name": appSettings.app_name,
    "environment": appSettings.environment,
    "loki_addr": appSettings.loki_addr,
    "request_id": request_id.get()
  }
